package com.ldc.wandroid;

import android.app.Application;

import androidx.room.Room;

import com.ldc.common.ApplicationBase;
import com.ldc.common.common.AndroidExceptionCache;
import com.ldc.wandroid.db.AppDatabase;
import com.ldc.wandroid.db.DbDtMigrate;

import cn.jpush.android.api.JPushInterface;


public class MyApp extends ApplicationBase {

    private static AppDatabase database;

    public static AppDatabase getDatabase() {
        return database;
    }


    @Override
    protected void initApp(Application application) {
        //极光推送配置
        JPushInterface.setDebugMode(true);
        JPushInterface.init(application);
        //数据库
        database = Room.databaseBuilder(application, AppDatabase.class, "wandroid.db")
                .allowMainThreadQueries()//主线程可查
                .addMigrations(DbDtMigrate.v_1_2_2)
                .build();
        Thread.setDefaultUncaughtExceptionHandler(new AndroidExceptionCache());
    }
}
